<template>
  <view>
    <pagehead>{{title}}</pagehead>
    <view class="view" v-if="type=='03'">
        <image :src="IMAGE_STATIC+'/userimage/authorizationCertificate.jpg'" lazy-load class="img" mode="widthFix"
      style="width: 100%;"></image>
      <view class="name">{{ dataAuthorize.name }}</view>
      <view class="id_card">{{ dataAuthorize.id_card }}</view>
      <view class="cert_no">{{ dataAuthorize.cert_no }}</view>
      <view class="date">{{ dataAuthorize.date }}</view>
      </view>
    <view class="content" v-else>
      <!-- <image :src="imgShow(item.img_url)" v-for="(item, index) in content" :key="index" lazy-load class="img" mode="widthFix"
        style="width: 100%;"></image> -->
        <init-image :src="imgShow(item.img_url)" v-for="(item, index) in content" :key="index" mode="widthFix" />  
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      IMAGE_STATIC: this.$url.assetsPath, //图片资源
      content: '授权证书',
      title:'',
      dataAuthorize:'',
      type:''
    };
  },
  onLoad(options) {
    if(options){
      console.log(options)
      this.type = options.value1
      this.title = options.value2
    }
    if(this.type){
      this.getData()
    }
    if(this.type=='03'){
      this.getUserAuthorize()
    }
  },
  methods: {
    getData() {
      const data = {
        img_type: this.type
      }
      this.$Ajax('/api/system/appImg/getAppImgList', data, res => {
        if (res.success) {
          this.content = res.data.appImgList
        }
      })
    },
    // 获取授权信息
    getUserAuthorize() {
      const data = {
      }
      this.$Ajax('/api/user/info/getUserAuthorize', data, res => {
        if (res.success) {
          this.dataAuthorize = res.data
          const date = this.forMatDate(this.dataAuthorize.date)
          this.dataAuthorize.date = date
          console.log('date',date)
        }
      })
    },
    forMatDate(value){
      var dataTime = "";
      var data = new Date(value);
      // data.setTime(value);
      var year = data.getFullYear();
      var month_temp = data.getMonth() + 1;
      var month = month_temp < 10 ? '0' + month_temp : month_temp;
      var day = data.getDate();
      console.log(year,month_temp,day)
      return year+'年'+month_temp+'月'+day+'日'
    }
  },
};
</script>

<style lang="scss" scoped>
.content {
  padding: 40rpx 20rpx;
}

image,
img,
video {
  max-width: 100%;
  margin: auto;
}
.view{
  position: relative;
  font-size: 24rpx;
  color: #333;
  .name{
    position: absolute;
    top: 35.5%;
    left:32.3% ;
  }
  .id_card{
    position: absolute;
    top: 39.5%;
    left:35% ;
  }
  .cert_no{
    position: absolute;
    top: 69%;
    left:31.5% ;
  }
  .date{
    position: absolute;
    right: 10%;
    bottom: 17.5%;
  }
}
</style>
